const {
    findSubstring,
    getRightList
} = require('./../串联所有单词的子串');
const {
    CreateSeries,
    CreateSeriesMerge
} = require('./../utils/createSeries');

function test_() {
    let s = "abbaccaaabcabbbccbabbccabbacabcacbbaabbbbbaaabaccaacbccabcbababbbabccabacbbcabbaacaccccbaabcabaabaaaabcaabcacabaa";
    let words = ["abc","aaa","aab","cac","aba"].reverse();
    let ret = [];
    // getRightList(words).forEach(ws => {
    //     console.log(ws);
    //     ret = ret.concat(findSubstring(s,ws,true));
    // });
    ret = findSubstring(s,words);
    return JSON.stringify(ret) === JSON.stringify([97]);
}

function test2() {
    let s = "abcbaaaccaabbcababaaabccaabccccbbccbaabcbccacacacabcbbbacbcbbccabaccbbbcbaabbabbaaaacaacbcacbbaacbcbcbabbbcacbbacaacbbbcacccbbcacabbbacaccbcbaababa";
    let words = ["bcb","baa","cac","aca","cca"];
    let ret = [];
    getRightList(words).forEach(ws => {
        console.log(ws);
        ret = ret.concat(findSubstring(s,ws,true));
    });
    // ret = findSubstring(s,words,false);
    return JSON.stringify(ret) === JSON.stringify([35]);
}

function test3() {
    let s = "bccbcc";
    let words = ["bc","cc","cb"];
    let ret = [];
    // getRightList(words).forEach(ws => {
    //     console.log(ws);
    //     ret = ret.concat(findSubstring(s,ws,true));
    // });
    ret = findSubstring(s.substring(0),words,false);
    return JSON.stringify(ret) === JSON.stringify([0]);
}

function test4() {
    let s = "abaababbaba";
    let words = ["ab","ba","ab","ba"];
    let ret = [];
    // getRightList(words).forEach(ws => {
    //     console.log(ws);
    //     ret = ret.concat(findSubstring(s,ws,true));
    // });
    ret = findSubstring(s.substring(0),words,false);
    return JSON.stringify(ret) === JSON.stringify([1,3]);
}

function test5() {
    let s = "abbccbc";
    let words = ["bc","cc","bb"];
    let ret = [];
    // getRightList(words).forEach(ws => {
    //     console.log(ws);
    //     ret = ret.concat(findSubstring(s,ws,true));
    // });
    ret = findSubstring(s.substring(0),words,false);
    console.log(ret);
    return JSON.stringify(ret) === JSON.stringify([1]);
}

function test6() {
    let s = "pjzkrkevzztxductzzxmxsvwjkxpvukmfjywwetvfnujhweiybwvvsrfequzkhossmootkmyxgjgfordrpapjuunmqnxxdrqrfgkrsjqbszgiqlcfnrpjlcwdrvbumtotzylshdvccdmsqoadfrpsvnwpizlwszrtyclhgilklydbmfhuywotjmktnwrfvizvnmfvvqfiokkdprznnnjycttprkxpuykhmpchiksyucbmtabiqkisgbhxngmhezrrqvayfsxauampdpxtafniiwfvdufhtwajrbkxtjzqjnfocdhekumttuqwovfjrgulhekcpjszyynadxhnttgmnxkduqmmyhzfnjhducesctufqbumxbamalqudeibljgbspeotkgvddcwgxidaiqcvgwykhbysjzlzfbupkqunuqtraxrlptivshhbihtsigtpipguhbhctcvubnhqipncyxfjebdnjyetnlnvmuxhzsdahkrscewabejifmxombiamxvauuitoltyymsarqcuuoezcbqpdaprxmsrickwpgwpsoplhugbikbkotzrtqkscekkgwjycfnvwfgdzogjzjvpcvixnsqsxacfwndzvrwrycwxrcismdhqapoojegggkocyrdtkzmiekhxoppctytvphjynrhtcvxcobxbcjjivtfjiwmduhzjokkbctweqtigwfhzorjlkpuuliaipbtfldinyetoybvugevwvhhhweejogrghllsouipabfafcxnhukcbtmxzshoyyufjhzadhrelweszbfgwpkzlwxkogyogutscvuhcllphshivnoteztpxsaoaacgxyaztuixhunrowzljqfqrahosheukhahhbiaxqzfmmwcjxountkevsvpbzjnilwpoermxrtlfroqoclexxisrdhvfsindffslyekrzwzqkpeocilatftymodgztjgybtyheqgcpwogdcjlnlesefgvimwbxcbzvaibspdjnrpqtyeilkcspknyylbwndvkffmzuriilxagyerjptbgeqgebiaqnvdubrtxibhvakcyotkfonmseszhczapxdlauexehhaireihxsplgdgmxfvaevrbadbwjbdrkfbbjjkgcztkcbwagtcnrtqryuqixtzhaakjlurnumzyovawrcjiwabuwretmdamfkxrgqgcdgbrdbnugzecbgyxxdqmisaqcyjkqrntxqmdrczxbebemcblftxplafnyoxqimkhcykwamvdsxjezkpgdpvopddptdfbprjustquhlazkjfluxrzopqdstulybnqvyknrchbphcarknnhhovweaqawdyxsqsqahkepluypwrzjegqtdoxfgzdkydeoxvrfhxusrujnmjzqrrlxglcmkiykldbiasnhrjbjekystzilrwkzhontwmehrfsrzfaqrbbxncphbzuuxeteshyrveamjsfiaharkcqxefghgceeixkdgkuboupxnwhnfigpkwnqdvzlydpidcljmflbccarbiegsmweklwngvygbqpescpeichmfidgsjmkvkofvkuehsmkkbocgejoiqcnafvuokelwuqsgkyoekaroptuvekfvmtxtqshcwsztkrzwrpabqrrhnlerxjojemcxel";
    let words = ["dhvf","sind","ffsl","yekr","zwzq","kpeo","cila","tfty","modg","ztjg","ybty","heqg","cpwo","gdcj","lnle","sefg","vimw","bxcb"];
    let ret = [];
    // getRightList(words).forEach(ws => {
    //     console.log(ws);
    //     ret = ret.concat(findSubstring(s,ws,true));
    // });
    ret = findSubstring(s.substring(0),words,);
    console.log(ret);
    return JSON.stringify(ret) === JSON.stringify([1]);
}

let allTest = [test_,test2,test3,test4,test5,test6].map((t, ind) => {
    if (!t()) {
        console.log(`test${ind + 1} fail`)
    }
});
